/*
 * Copyright 2010-2012 Susanta Tewari. <freecode4susant@users.sourceforge.net>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package coalescent.is.cef.pui;

import cef.event.Event;
import cef.pui.EventConstructionException;
import cef.pui.EventImpl;
import cef.pui.pob.Builder;
import cef.pui.pob.Builders;
import coalescent.cef.pui.pob.Builders_Coa;
import coalescent.data.K69Data;
import coalescent.is.cef.event.AppNoteIS_Evt;
import coalescent.model.K69;
import commons.core.Generator;
import commons.core.Simulator;

import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

import static cef.pui.pob.Builders.of_Integer;

/**
 * @author Susanta Tewari
 * @version version
 * @history Created on 11/14/13.
 * @since since
 */
public class AppNoteIS_EvtImpl extends EventImpl implements AppNoteIS_Evt {

    /** sample size builder */
    private final Builder<List<Integer>> sample_size_b;
    private final Builder<Integer> dataSimCount_b;

    /** theta values for the model generator */
    private final Builder<List<Double>> thetaValues_b;

    /** model generator builder */
    private final Builder<Generator.MODEL<List<Double>, K69>> mg_b;

    /** data simulator builder */
    private final Builder<Simulator.DATA<K69, K69Data>> ds_b;

    /**
     * @param props properties as specified in the class javadoc
     * @throws cef.pui.EventConstructionException
     *          if error in properties
     */
    public AppNoteIS_EvtImpl(Properties props) throws EventConstructionException {

        super(props);

        super.processEventProperties(getImplementedEventInterfaces());


        // builder: sample size, modelCount
        dataSimCount_b = of_Integer(props, "dataSimCount", "coalescent.k69.dataSimulator");
        sample_size_b  = Builders.of_List_Int(props, "sampleSizes", null);
        thetaValues_b  = Builders.of_List_Double(props, "thetaValues", null);


        // builders: other
        mg_b = Builders_Coa.of_Generator_Model_K69(props, null);
        ds_b = Builders_Coa.of_Simulator_Data_K69(props, null);
    }

    @Override
    protected List<Class<? extends Event>> getImplementedEventInterfaces() {

        final List<Class<? extends cef.event.Event>> result = new ArrayList<>(2);

        result.add(AppNoteIS_Evt.class);
        result.add(Event.class);

        return result;
    }

    @Override
    public List<Double> getThetaValues() {
        return thetaValues_b.build();
    }

    @Override
    public List<Integer> getSampleSizes() {
        return sample_size_b.build();
    }

    @Override
    public int getDataSimulationCount() {
        return dataSimCount_b.build();
    }

    @Override
    public Generator.MODEL<List<Double>, K69> getModelGenerator() {
        return mg_b.build();
    }

    @Override
    public Simulator.DATA<K69, K69Data> getDataSimulator() {
        return ds_b.build();
    }
}
